# 1. 自动取款机用户数据源
stu_list = [
    {'name':'wangtian','money':3000,'atmtype':'jianshe'},
    {'name':'xiaobai','money':2000,'atmtype':'youzheng'},
    {'name':'xiaohei','money':5000,'atmtype':'gongshang'}
          ]

# 2.查看用户余额信息
def show_stu_info():
    '''

    :return:
    '''
    if len(stu_list) ==0:
        print('='*20,'银行没有该用户信息','='*20)
        return

    print('|{0:<5}|{1:<10}|{2:<5}|{3:<10}|'.format('sid','name','money','atmtype'))
    print('-'*40)
    for i , stu_dict in enumerate(stu_list):
        print('|{0:<5}|{1:<10}|{2:<5}|{3:<10}|'.format(i+1,stu_dict['name'],stu_dict['money'],stu_dict['atmtype']))
# 2.测试查看老板的账户信息
show_stu_info()

# 3.存入金额信息操作
def add_stu(name,money,atmtype):
    stu_dict = {}
    stu_dict['name'] = name
    stu_dict['money'] = money
    stu_dict['atmtype'] = atmtype
    stu_list.append(stu_dict)
    # 3.测试老板存钱操作
add_stu('hhh', '1500', 'gongshang')
show_stu_info()

# 4.取钱信息操作
def del_stu(sid):
    sid_int = int(sid)
    stu_list.pop(sid_int-1)

    # 4.测试老板取钱，必须一次取完哦
del_stu(3)
show_stu_info()

# 5.退出系统
def loginOut():
    pass

# 6.交互页面
while True:
    #输出初始界面
    print('='*15,'自动存取款机模拟机','='*15)
    print('{:1}{:13}{:15}'.format(' ','1. 查看老板资金信息','2. 老板建户工作'))
    print('{:1}{:13}{:15}'.format(' ', '3. 老板销户操作', '4. 退出系统'))
    print('='*40)
    key = input('请输入对应的选择')
    #根据输入操作值，执行对应的操作
    if key =='1':
        print('='*12,'查看老板资金信息','='*12)
        show_stu_info()
        input('按回车键继续:')
    if key == '2':
        print('=' * 12, '老板存入金钱', '=' * 12)
        name = input('请输入名字：')
        age = input('请输入存入金额:')
        classid = input('请输入存入银行类型:')
        add_stu(name,age,classid)
        show_stu_info()
        input('按回车键继续:')
    elif key == '3':
            print('=' * 12, '老板取钱操作', '=' * 12)
            show_stu_info()
            sid = input('请输入要取金额的sid值:')
            del_stu(sid)
            show_stu_info()
            input('按回车键继续:')
    elif key == '4':
           loginOut()
           print('='*12,'再见','='*12)
           break
    else:
        print('操作无效')
